package com.truyen.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.truyen.service.JsoupService;
import com.truyen.service.TaskScheduleService;
import com.truyen.service.TruyenKiemHiepService;
import com.truyen.service.TruyenTinhCamService;
import com.truyen.service.TruyenTranhService;
import com.truyen.service.TruyenTrinhThamService;


@Service
public class TaskScheduleServiceImpl implements TaskScheduleService {
	
	@Autowired
	private TruyenTranhService truyenTranhService;
	
	@Autowired
	private TruyenKiemHiepService truyenKiemHiepService;
	
	@Autowired
	private TruyenTinhCamService truyenTinhCamService;
	
	@Autowired
	private TruyenTrinhThamService truyenTrinhThamService;
	
	@Autowired
	private JsoupService jsoupService;
	
	// lap lich cap nhat viewsWeek ve 0 vao 0h0' hang tuan
	@Scheduled(cron = "${cron.updateViewsWeek}")
	public void updateViewsWeek() {
		truyenTranhService.updateViewsWeek();
		truyenKiemHiepService.updateViewsWeek();
		truyenTrinhThamService.updateViewsWeek();
		truyenTinhCamService.updateViewsWeek();
	}
	
	// lap lich cap nhat viewsWeek ve 0 vao 0h0' hang thang
	@Scheduled(cron = "${cron.updateViewsMonth}")
	public void updateViewsMonth() {
		truyenTranhService.updateViewsMonth();
		truyenKiemHiepService.updateViewsMonth();
		truyenTrinhThamService.updateViewsMonth();
		truyenTinhCamService.updateViewsMonth();
	}
	
	@Scheduled(cron = "${cron.getTruyen}")
	public void getTruyen(){
		jsoupService.getLinkSourceAllTruyenFromBlogTruyen("TatCa");
		jsoupService.getLinkSourceTruyenKiemHiepFromHixx();
		jsoupService.getLinkSourceTruyenTinhCamFromHixx();
		jsoupService.getLinkSourceTruyenTrinhThamFromHixx();
//		jsoupService.getLinkSourceTruyenMa();
//		jsoupService.getLinkSourceTruyenMaTGM();
		jsoupService.getLinkAlbum();
	}
	
//	@Scheduled(cron = "${cron.getChapterTruyen}")
//	public void getChapterTruyen(){
//		jsoupService.getImagevLstChapterOfComicBlogTruyen();
//		jsoupService.getImageInfoChapterTruyenKiemHiepFromHixx();
//		jsoupService.getImageInfoChapterTruyenTinhCamFromHixx();
//		jsoupService.getImageInfoChapterTruyenTrinhThamFromHixx();
//		jsoupService.getContentChapterTruyenMaTGM();
//	}
	
//	@Scheduled(cron = "${cron.getContentChapter}")
//	public void getContentChapterTruyen(){
//		jsoupService.getContentChapterOfComicBlogTruyen();
//		jsoupService.getContentChapterTruyenKiemHiepFromHixx();
//		jsoupService.getContentChapterTruyenTinhCamFromHixx();
//		jsoupService.getContentChapterTruyenTrinhThamFromHixx();
//		jsoupService.getContentChapterTruyenMa();
//		jsoupService.updateAlbum();
//	}
	
//	@Scheduled(cron = "${cron.getContentChapterTamTruyenMaTGM}")
//	public void getContentChapterTamTruyenMaTGM(){
//		jsoupService.getContentChapterTamTruyenMaTGM();
//	}
}
